/**===================**
  date:2012-04-01
  by:globalbreak@gmail.com 诸葛浮云
  Copyright © 2012 - Anwsion社区, All Rights Reserved
  
**===================**/



(function(w){
	var contxt = w.document,
		location = w.location,
	    Navigator = w.navigator,
		isIEtxt = '<style type="text/css">.isIE6{ background:#feb300; border-bottom:1px solid #dfdfdf; height:40px; line-height:40px; font-size:18px; font-weight:bold; color:#000; font-family:"微软雅黑"; padding:0 20px; text-align:center;width:100%;white-space:nowrap;}.isIE6 a{ color:blue;}.isIE6 a:hover{color:blue; text-decoration:underline;}</style><div class="isIE6">你目前使用的浏览器版本过低，将不能使用本站部分功能。请升级你的 <a href="http://windows.microsoft.com/zh-CN/internet-explorer/downloads/ie-8">Internet Explorer 浏览器</a>获取最佳的浏览效果。</div>';
		this.len = 0;
		this[0] = contxt.body;
		
	//ie检测	
	if(Navigator.appName === 'Microsoft Internet Explorer'){
		var e = Navigator.appVersion;
		var msIE = e.match(/MSIE \d\.\d/);
		
		if(msIE == "MSIE 6.0" || msIE == "MSIE 5.5"){
			var div = contxt.createElement("div");
				div.className = 'isIE';
			    div.innerHTML = isIEtxt;
			    this[0].appendChild(div);
				this[0].className ='pd';
		}
	}  

	
		
		
	var  myFun = function(arg){
			var that = this ;
		    return {
				_$id : function(){var el = arg[0]; if(typeof el == 'string'){return contxt.getElementById(el) } },
				
				each : function(o,myFun){
					for(var i = 0 ,len= o.length; i< len; i++){
						myFun.call(this,o[i],i);
					}
				},
				
				setStyle:function(el,prop,val){return el.style[prop] = val ;},
				
				show:function(el){return this.setStyle(el,'display','block');},
				
				hide:function(el){return this.setStyle(el,'display','none');},
				
				addEvent:function( el,e,fn ){
					
					if( window.addEventListener ){
						el.addEventListener( e,fn,false);
						
					}else if( window.attachEvent ){
						el.attachEvent('on'+e,fn);
					}
				},
				
				byClassName : function(str){
					
					var elements = [] ,j = 0;
					var tag = str == null ? '*' : str ;
					
					if(typeof tag == 'string'){
						element = contxt.getElementsByTagName(tag);
						this.each(element,function(el,i){
						
							if( el.className === arg[0] ){
								elements.push(el);
							}
						})
						return elements;
					}
					
				}
			}//end return 
		}//end myFun
	
	window['_$'] = function(){return new myFun(arguments);}
	
})(window);

//html5 for ie browser
//(function(d){var e = "abbr,article,aside,audio,canvas,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while(i--){d.createElement(e[i])}})(document);


//头部搜索
var default_Search = {
	
	s : function(el){ return  typeof el === 'string' ? document.getElementById(el) :el; },
	//events
	keyEvents : 'onkeydown' && 'onkeyup',
	
	_v2date : null,
	
	_v2Value:null,
	
	//监测事件
	monitor_events : function(){
		
			var seif_id =  this.default_id = this.s('global_search'),_v2seif = this;
			var s_id = _v2seif.s('default_search');
			
			seif_id[this.keyEvents] = function(){
				
				this._v2Value = this.value.replace(/^\s+/,'').replace(/\s+/g,'');
				var url = G_BASE_URL+'/search/ajax/search/q-'+encodeURIComponent(this.value)+'__limit-5';
				
				if(this._v2Value.length >0){
					_v2seif.setSearchAjax(url,this._v2Value);
				}else{
					s_id.className = 'default_search hide';
				}
				
				var docEvent = document.onclick = function(e){
					
					if(elementClickEvent.letter.getTag(e).className != 'start_question' &&
					   elementClickEvent.letter.getTag(e).className != 'default_blue_but'&&
					   elementClickEvent.letter.getTag(e).nodeName != 'B' &&
					   elementClickEvent.letter.getTag(e).nodeName != 'LI'&&
					   elementClickEvent.letter.getTag(e).className != 'default_list'&&
					   elementClickEvent.letter.getTag(e).className != 'default_search'
					){
						
						s_id.className = 'default_search hide';
						docEvent = null;
					}
					
				}
			}
			
			
		return this;
	},
	
	setSearchAjax : function(url,objVale){
		
		this._v2date = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
		this._v2date.onreadystatechange = this.statechange;
		this._v2date.open("post",url,true);
		this._v2date.send(null);
	},
	
	gl_search : function(){
		
		var gl_search = this.s('gl_search'),_v2seif =this;
		
			gl_search.onclick = function(){
				var _vals = _v2seif.s('global_search').value.replace(/^\s+/,'').replace(/\s+/g,'');
				if(_vals.length <= 0){
					
					default_alert('搜索不能为空！');
					return false;
				}else if(_vals.length <= 1){
					default_alert('多几个关键词搜索吧。');
					return false;
				}else{
					window.location = G_BASE_URL+'/search/q-'+_vals;
				}
				
			}
		return this;
	},
	statechange : function(){
		
		var s_id = default_Search.s('default_search'),elementsArr=[];
		var _v2Value = default_Search.default_id.value;
		
		var _v2html = '<li class="start_question"><a class="default_blue_but" href="javascript:;" rel="'+_v2Value+'" onclick="elementClickEvent.letter.moudleTips_start(\''+_v2Value+'\',elementClickEvent.letter.moudle_box().start_question); return false;" title="发起该问题">发起该问题</a><b>'+_v2Value+'</b></li>';
		
		if( default_Search._v2date.readyState == 4 && default_Search._v2date.status == 200 ){
				
		  var z = new Function('return '+ default_Search._v2date.responseText)();
		 
		  if((z && z!=null) && z!=''){
			  for(var i =-1,len =z.length; ++i<len;){
				
				if(z[i] && i <10){
				  var elment,el = z[i];
				  //问题
				  if(el.type == 1){
					elment = '<li><a class="c" href="'+el.url+'" title="'+el.name+'">'+(el.detail.best_answer <= 0 ? '' : '<span class="best_answer" title="最佳答案"></span>')+'<span class="s">'+(el.name.replace(new RegExp(_v2Value,"ig"),'<b>'+_v2Value+'</b>'))+'</span><span class="s_result">'+(el.detail.answer_count == null ? 0 : el.detail.answer_count)+' 个答案</span></a></li>';
				  }
				  
				  //话题
				  else if(el.type == 2){
					 elment = '<li><a href="'+el.url+'"><span class="s_topic" rel="'+el.sno+'" onmouseover="eventstalk(this);">'+el.name+'</span><span class="s_result">'+(el.detail.topic_count == null ? 0 : el.detail.topic_count)+'个问题</span></a></li>';
				  }
				  
				  //用户
				  else if(el.type == 3){
					 elment = '<li><a class="s_name a"  href="'+el.url+'"><img class="s_img" src="'+el.detail.avatar_file+'" rel="'+el.sno+'" onmouseover="eventsMouseM(this);"><span rel="'+el.sno+'" onmouseover="eventsMouseM(this);">'+el.name+'</span><span class="s_result">'+(el.detail.signature == null || el.detail.signature =='' ? '暂无签名' : el.detail.signature)+'</span></a></li>';
				  }
				  
				 elementsArr.push(elment);
			  }
			 
			  s_id.innerHTML = '<ul class="default_list">'+elementsArr.join('')+'<li><a class="a"  href="'+G_BASE_URL+'/search/q-'+_v2Value+'" title="点击对 '+_v2Value+' 进行相关搜索 »">搜索：'+_v2Value+'</a></li>'+_v2html+'</ul>';
			  }
		  }else{
			
			s_id.innerHTML = '<ul class="default_list"><li class="start_question"><a class="default_blue_but" href="javascript:;" onclick="elementClickEvent.letter.moudleTips_start(\''+_v2Value+'\',elementClickEvent.letter.moudle_box().start_question); return false;" title="发起该问题">发起该问题</a><b>暂无相关内容，你可以继续</b></li></ul>';
		  }
	    }else{
			s_id.className = 'default_search';
			s_id.innerHTML = '<p style="padding:10px;color:#999;"><img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...</p>';
		}
	},
	
	info : function(){
		
		if(this.s('global_search')){
			
			this.monitor_events().gl_search();
		}
		
	},
	
	//快捷键提交
	
	keyEvent : function(e){
		
		var e = e ? e : window.event;
		
		if((e.ctrlKey && e.keyCode == 13) || (e.ctrlKey && e.keyCode == 10)){
		
			_$("re_default_submit")._$id().onclick();
		}
	}
	
	
};

_$(window).addEvent(window,"load",function(){
										   
	var txt ='搜索话题、问题或人...';
	 try{
		var el = _$("s_txt");
	 	var eletxt = el._$id();
		
		el.addEvent(eletxt,'focus',function(){elEvent(eletxt,txt,'');})
		el.addEvent(eletxt,'blur',function(){elEvent(eletxt,'',txt);})
	 }catch(exp){}
	 
	 //
	 
	 
	 //评论框
	
	if( _$("answer_content")._$id()){
			var textArea =  _$("answer_content")._$id();
			textArea['onkeydown' && 'onkeyup'] = function(){
				
				this.style.overflowY = 'hidden';
				
				if(this.scrollHeight >= 500){
				
					this.style.height = '500px';
					this.style.overflowY = 'auto';
					return false;
				}
				
				this.style.height = '0px';
				if(this.scrollHeight >=100){
				
					this.style.height = '0px';
					this.style.height = this.scrollHeight + 50 + 'px';
					
				}else{
					
					this.style.height = '113px';
				}
				
				
				
			}
			textArea.onfocus = function(){
			
					document.onkeypress = default_Search.keyEvent
			}
			
	}

	default_Search.info(); 
	
	
	
})

//搜索调用
function elEvent(el,s,e,newclass){
	var cl = el.className;
	var myclass = cl == null ? '': cl;
	
	if(el.value==s){
		el.value=e;el.className = newclass == null ? myclass : newclass;
	}
};

//计时器
setInterval('check_notifications()', 60000);

$(document).ready(function () {
	
	check_notifications();

	// Date picker
	$('input.date_picker').date_input();
	
	$("a[rel=lightbox]").fancybox({
		maxWidth	: ($(window).width() * 0.8),
		maxHeight	: ($(window).height() - 0.8),
		fitToView	: false,
		width		: '80%',
		height		: '80%',
		autoSize	: true,
		closeClick	: true,
		arrows		: false,
		keys		: false
	});
	
	$('#tip_success_message').hide();
});



//ajax缓存
var ajax_date = [];

//用户回复
var default_arr = [] ;

var strClick_show = function(){};	

strClick_show.prototype.edit_inputs = function( str ){
	
	var _this = this;
	this.editDiv  = document.getElementById( str );
	
	this.editDiv['onfocus'] = this.i_focus;
	this.editDiv['onblur'] = this.i_blur;
	this.editDiv['onkeydown' &&'onkeyup'] = function(event){
		_this.i_keyUp(this,_this,event);
	}
	this.elValues =[];
}

//历史记录 操作
strClick_show.prototype._histroyClick = function( obj,inpTips ){
	
	var parentNodes = obj.parentNode.getElementsByTagName('div')[0],ar=[];
	var elements = parentNodes.getElementsByTagName('p'),_this = this;
	this.gid(inpTips).className = 'user_teamLister hide';
	
	if(obj.className == 'str_click'){
		
		obj.className = 'str_click cur';
		parentNodes.className = 'i_teamLister';

		for(var i =-1,len =elements.length; ++i<len;){
			
			(function(i){
			
				var el = elements[i];
				el['onclick'] = function(){
	
					var tagA = el.getElementsByTagName("a");
					for(var k =-1,len =tagA.length; ++k<len;){
						
						ar.push(tagA[k].rel);
						_this.editDiv.setAttribute("value",ar);
						_this.editDiv.value = ar;
					}
					
					obj.className = 'str_click';
					parentNodes.className = 'i_teamLister hide';
				}
				
			})(i)
		}
		
	}else if(obj.className == 'str_click cur'){
		
		obj.className = 'str_click';
		parentNodes.className = 'i_teamLister hide';
	}

	
	
	document.onclick = function(event){
	
		var event = event ? event : window.event;
		var trg = event.target || event.srcElement;
		
		if(trg.nodeName !="A" && trg.nodeName !="P"){
		
			obj.className = 'str_click';
			parentNodes.className = 'i_teamLister hide';
			document.onclick = null;//销毁事件
		}
		
	}
}

strClick_show.prototype.changes_Click = function( obj,str ){
	
	var clickshowDiv = document.getElementById(str);
	if(obj.getAttribute("value")=='personal'){
	
		clickshowDiv.className = 'i_divUserInpt hide'
		
	}else if(obj.getAttribute("value")=='teams'){
	
		clickshowDiv.className = 'i_divUserInpt'
	}
}



strClick_show.prototype.i_focus = function(){
	
	if( this.value =='限站内用户(用空格隔开)'){
		
		this.value ='';
	}
}

strClick_show.prototype.i_blur = function(){
	
	if( this.value ==''){
		
		this.value ='限站内用户(用空格隔开)';
	}
}

strClick_show.prototype.i_keyUp = function(str,obj,e){
	
	var listerTeam = str.parentNode.getElementsByTagName('div')[0];
	var elements = listerTeam.getElementsByTagName('p'),strValue = str.value.replace(/\s/g,'');
	var e = e ? e : window.event;
	
	if(strValue ==''|| strValue ==',' || e.keyCode =='188'){
		
		listerTeam.className = 'user_teamLister hide'
	}else{
		
		listerTeam.className = 'user_teamLister';

		
		var objVALUES = strValue.charAt(strValue.length-1);
		this.elValues.push(objVALUES);
		
		if(objVALUES !='' && objVALUES !=','){
			
			var url = G_BASE_URL + '/search/ajax/search/type-user__q-' + encodeURIComponent(objVALUES) + '__limit-10';
			obj.XHRAjax(url,listerTeam);
		}
	
	}

	document.onclick = function(event){
	
		var event = event ? event : window.event;
		var trg = event.target || event.srcElement;
		
		if(trg.nodeName !="A" && trg.nodeName !="P"){
		
			listerTeam.className = 'user_teamLister hide';
			document.onclick = null;//销毁事件
		}
		
	}
}

strClick_show.prototype.XHRAjax = function( url,strObj ){
					
	var xhr,docm = document,elementsArr =[];
	
	try{
		strObj.innerHTML='<img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...';
		xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
		xhr.open("post",url,true);
		xhr.onreadystatechange = function(){
		
			if( xhr.readyState == 4 && xhr.status == 200 ){
		
				var xml = new Function('return '+xhr.responseText)();
				if(xml!=null && xml!=''){
					for(var i =-1,len =xml.length; ++i<len;){
						
						var elment,el = xml[i];
							elment = '<a href="javascript:;" id="'+el.uid+'" rel="'+el.name+'" onclick="elementClickEvent.addElementValue(this);">'+el.name+'</a>'
							elementsArr.push(elment);
							
					}
					strObj.innerHTML = elementsArr.join('');
				}else{
					
					strObj.innerHTML ='sorry！没有查询到你要的团队.';
				}
			}
		};
		xhr.send(null);
		
	}catch(e){
		
		alert(e)
	}
}


strClick_show.prototype.addElementValue = function(str){
	
	
	var elementArr=[],historyArr ='',objValues = this.editDiv.value.replace(/\s/g,''),rels;
	if(objValues.length >1){ //split(',');
		
		historyArr = objValues;
		for(var i=-1,len=historyArr.split(',').length;++i<len;){
			
			
			if(historyArr.split(',')[i] != this.elValues.join('')){
				
				elementArr.push(historyArr.split(',')[i]);
			}
			if(historyArr.split(',')[i] == str.rel){	
				
				new DialogBox_show( '250', '不能重复添加！','提示','确定');
				return false;
			}
		}
		
	}
	elementArr.push(str.rel);
	
	this.editDiv.setAttribute("value",elementArr+',');
	this.editDiv.value = elementArr+',';
	
	if(str.parentNode.nodeName=='DIV'){
		
		str.parentNode.className ='user_teamLister hide';
		this.elValues=[];
		historyArr=''
	}
	
}

//个人中心
strClick_show.prototype.EveClick = function( o,n,obj ){
	
	this.elementHide(o,'layer','detaListerDiv hide');
	var markId = this.gid('layer'+n);
	obj.className = 'cur';
	markId.className = 'detaListerDiv';
	
	if(n==1 && markId.id =='layer1' || n==2 && markId.id =='layer2'){
		
		this.elements_Clicks(markId,n)
		
	}
}


strClick_show.prototype.Project_Tabs = function( a,b,c,d,n ){

	var e = [a.rel,b,c,d],g='',dc = document,
		f = 'uLister_proJect_tags|Lister_attentionPersonal_fh|Lister_attentionPersonal|Lister_attentionPersonal_fm',
		k = f.split("|");
		this.uLister = this.gid('uLister').getElementsByTagName('a');
	
	for(var i in e){
		
		var vk = e[i];
		for(var s in e){
			this.gid(e[s]).className ='hide';
		}
		
		switch(vk){
			case k[0]:
			this.tabs_mark(a,vk,n);
			return false;
			break;
			
			case k[1]:
			this.gid(vk).className ='';
			this.eliminate('');
			return false;
			break;
			
			case k[2]:
			this.gid(vk).className ='';
			this.eliminate('');
			return false;
			break;
			
			case k[3]:
			this.gid(vk).className ='';
			this.eliminate('');
			return false;
			break;
		}
		
	}
	
	this.hideLister(this.uLister);
}

strClick_show.prototype.children_Clicks = function( o,n,t ){
	
	var element = o[n] ,_this = this;
	element['onclick'] = function(){
		
		if(t==1){
			_this.elementHide(o,'layer_','oDivClassTabs hide');
			_this.gid('layer_'+n).className = 'oDivClassTabs';
		}else if(t==2){
			_this.elementHide(o,'layer_t','oDivClassTabs hide');
			_this.gid('layer_t'+n).className = 'oDivClassTabs';
		}
		element.className ='cur';
	}
	
}

strClick_show.prototype.elementHide = function( o,str,clas ){
	
	for(var i =-1,len=o.length;++i<len;){
		
		this.gid(str+i).className = clas;
		o[i].className = '';
	}
}

strClick_show.prototype.hideLister = function(str){
	
	if(str!=null){
		
		for(var i =-1,len=str.length;++i<len;){
	
			str[i].className = '';
		}
		
	}
}

strClick_show.prototype.gid = function(o){
	var d = document,id;
	id = 'string' === typeof o ? d.getElementById(o) : o ;
	return id;
}

strClick_show.prototype.tabs_mark = function( o,str,n ){
	
	var elementDiv = this.gid(str);
	var elementH2 = this.uLister;
	
	elementDiv.className ='';
	this.EveClick(elementH2,n,o);
	if(n >= 3 && this.total_Integral!='function'&& this.total_Integral!=null ){
		this.total_Integral();
		
	}
	
}

strClick_show.prototype.eliminate = function(str){
	
	
	for(var i =-1,len=this.uLister.length;++i<len;){
		
		this.uLister[i].className = str;
	}
	
}

strClick_show.prototype.elements_Clicks = function( o,n ){
	
	var mark_ul = o.getElementsByTagName('ul')[0];
	var omg_li = mark_ul.getElementsByTagName('li');
	
	for(var i =-1,len=omg_li.length;++i<len;){
		
		this.children_Clicks(omg_li,i,n);
	}
	
}

//展开操作
strClick_show.prototype.Click_spread = function( a,b,c,d,e,fn ){
	
	var f = a.parentNode,g=true;
	
	if(g){
		a.className = a.className != b ? b : d ;
		f.className = f.className != c ? c : e ; 
		g = false;
	}
	
	//回调
	if(fn!=null && !g){
		fn(); 
	}
}	

strClick_show.prototype.c_funTXT = function( a,b,c ){
	
	a.title = a.title != b ? b : c;
}

strClick_show.prototype.c_delSeif = function(str){
	
	str.style.display = 'none';
}


//积分 
strClick_show.prototype.total_Integral = function(){

	
	if(this.gid('totat_percentum')!=null){
		
		var totat_percentum = this.gid('totat_percentum');
		this.setAjax(totat_percentum);
	}
	
};

strClick_show.prototype.setAjax = function(id){
	
	
	var totatTum=[],parameter=0,inner='';
	var _this = this,xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
	
		xhr.open("post", G_BASE_URL + '/people/ajax/user_integral_ratio_json/uid-' + G_USER_ID, true);
		xhr.onreadystatechange = function(){
				
			if( xhr.readyState == 4 && xhr.status == 200 ){
				
				var elements = new Function('return '+xhr.responseText)();
				
				for(var i in elements){
					
					if(elements[i].ratio >0){
						
						totatTum.push('<li><span class="tl_percentum">'+elements[i].name+'：</span><p class="shell_mark"><span class="progressBar" style="width:'+elements[i].ratio+'%;"></span><em class="cQ_Percentum">'+elements[i].ratio+'%</em></p></li>');
						 
					}else{
						
						totatTum.push('<li><span class="tl_percentum">'+elements[i].name+'：</span><p class="shell_mark delTum"><span class="progressBar" style="width:'+elements[i].ratio+'%;"></span><em class="cQ_Percentum">'+elements[i].ratio+'%</em></p></li>') 
						
					}
				}
				id.innerHTML = totatTum.join('');
				totatTum=[];
			}
			
		}
		xhr.send(null);

	
};



//赞同判断
strClick_show.prototype.schemeAgree = function(id){
	
	$(".spread").each(function(i){
		
		var element = $(".spread").eq(i);
		if(element.innerHeight() > 20 && element.parent().attr('class') =='Endorse'){
			
			element.parent().addClass('hide_end');
			if(element.parent().find('a').attr('class') == 'Click_moreErose'){
			
				element.parent().find('a').attr("onclick","elementClickEvent.Click_spread(this,'Click_moreErose','Endorse hide_end','Click_moreErose Click_spread','Endorse Endorse_Spread',elementClickEvent.c_funTXT(this,'查看更多>>','收起>>'))");	
			}
			
		}
	})
}

//返回顶部
strClick_show.prototype.return_Top = function(){
	
	var R = document.documentElement.scrollWidth || document.body.scrollWidth ;// safari firefox IE
	
	var  a = document.createElement('a');
		 a.href='javascript:;'; 
		 a.title='返回顶部';
		 a.className = 'return_Top hide';
		 a.setAttribute('onclick',' $("html,body").animate({scrollTop:0},"slow");');
		 a.style.left = (R-960)/2 +960 +'px';
		 document.getElementsByTagName('body')[0].appendChild(a);
		
	window.onscroll = function(){
	
		var Top = document.documentElement.scrollTop || document.body.scrollTop; 
		Top > 0 ? $(a).fadeIn('slow') : $(a).fadeOut('slow');
	}
}

//公用提示信息
function default_alert(html){
	
	var default_tag = $('<div/>')
				     .addClass('default_tips_tag hide')
					 .html('<div class="default_frame">'+
						   '<h2 class="anwsion_title"><a href="javascript:;" onclick="default_closeWindow();" class="close_ti" title="点击关闭对话框 "><em>close</em></a>提示信息</h2>'+
						   '<div class="default_txt"><p class="succes_v2">'+html+'</p></div>'+
						   '</div>')
					.appendTo(document.body).fadeIn('slow');
					
	var setTime = window.setTimeout(function(){
			
			$(default_tag).fadeOut('slow',function(){
					$(default_tag).remove();
					window.clearTimeout(setTime);	
			});
						
		},2000);
	
	
	
} 
function default_closeWindow(){
	if($('.default_tips_tag')!=null){
		$('.default_tips_tag').fadeOut('fast',function(){
				$('.default_tips_tag').remove();
		});	
	}
		
}

function returnAddEvent(){
	
	var strClick_shows = new strClick_show();
	strClick_shows.return_Top();
}

window.addEventListener ? window.addEventListener('load',returnAddEvent,false) : window.attachEvent('onload',returnAddEvent);



//站内分享
strClick_show.prototype.personalLetter = function(){
	
	var _thi = this;
	var title = '<a href="javascript:;" onclick="hidePupBox(\'w_tagPupD\',\'w_mask\');" class="close_ti" title="点击关闭对话框 "><em>close</em></a>分享';
	             
				 //tab切换
	this.html = '<ul id="menu_s">'+
					'<li class="cur" onclick="elementClickEvent.tabs(this,0);" rel="weibo">微博分享</li>'+
					'<li  onclick="elementClickEvent.tabs(this,1);" rel="mail">邮件分享</li>'+
					'<li  onclick="elementClickEvent.tabs(this,2);" rel="letter">站内信分享</li>'+
					'</ul>'+
					
					//微博分享
				'<div id="weibo_share" class="class_share">'+
					'<p class="sc-wb"><a title="新浪微博" href="'+G_BASE_URL+'/account/sina/binding/"><img src="' + G_STATIC_URL + '/common/icoSina.gif">绑定新浪微博帐号</a></p>'+
					'<p class="sc-wb"><a title="腾讯微博" href="'+G_BASE_URL+'/account/qq/binding/"><img src="' + G_STATIC_URL + '/common/share_tx_wb.gif">绑定腾讯微博帐号</a></p>'+
					'<p class="p">绑定微博之后，可以方便把精彩问答分享到该微博，并可以邀请你的微博好友来回复该问题或者加入 '+G_SITE_NAME+' </p>'+
					'<p class="sc-wb">已经绑定新浪微博账户：<a href="#">@stank</a></p><textarea class="txt_area" style="width:430px;"></textarea>'+
					'<p class="tr"><a href="javascript:;" onclick="hidePupBox(\'w_tagPupD\',\'w_mask\');">取消</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>'+
				'</div>'+
				
					//邮件分享
				'<div class="class_share hide" id="mail_share"><ul class="txt_list">'+
					'<li><label for="inputsType_txt">收件人：</label><input type="text" name="" class="txt_input"/></li>'+
					'<li><label for="inputsType_area">内容：</label><textarea class="txt_area"></textarea></li>'+
				'</ul><p class="tr"><a href="javascript:;" class="set_msg">发送</a><a href="javascript:;" onclick="hidePupBox(\'w_tagPupD\',\'w_mask\');">取消</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></div>'+
				
					//站内分享
				'<div class="class_share hide" id="letter_share"><ul class="txt_list">'+
					'<li><label for="inputsType_txt">发给：</label><input type="text" name="" class="txt_input" id="userShare_txt"/><div class="ajax_date hide"></div></li>'+
					'<li><label for="inputsType_area">内容：</label><textarea class="txt_area"></textarea></li>'+
				'</ul><p class="tr"><a href="javascript:;" class="set_msg">发送</a><a href="javascript:;" onclick="hidePupBox(\'w_tagPupD\',\'w_mask\');">取消</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></div>';
	
	new DialogBox_show('500',this.html,title,'',function(){
		
		_thi.gid('w_tagPupD').style.marginTop='-130px';
	});
}


//弹出框tab切换
strClick_show.prototype.tabs = function(o){
	
	var li = o.parentNode.getElementsByTagName('li');
	var a = o.getAttribute('uid');
	
	for(var i=-1,len=li.length;++i<len;){
		
		if(i==a && typeof o.getAttribute('rel')=='string' && o.getAttribute('rel')!=null){
			
			var id = this.gid(li[i].getAttribute('rel')+'_share');
			id.className ='class_share';
			li[i].className ='cur';
			
		}else{
			
			var id = this.gid(li[i].getAttribute('rel')+'_share');
			id.className ='class_share hide';
			li[i].className ='';
		}
		
	}
	
	if(o.getAttribute('rel')!=null && o.getAttribute('rel')=='letter'){
		
		this.letter.select_letters();
	}
}

//私信查询
strClick_show.prototype.letter = {
	
	getTag : function(event){
		
		var e = event ? event : window.event,tag = e.srcElement || e.target;
		return tag;
	},
	
	G : new strClick_show(),
	
	CacheClass:[],
	
	//window tips 发起问题
	moudleTips_start:function(str,fn,uid){
		
		
		//弹出框
		this.G.letter.moudle_box((typeof str === 'object' && str.category=='') ? '\'\'' : str.category).moudle_show_addDOM(this.G.letter.question_start);
		
		
		//添加话题
		//this.G.letter.default_Addtopic();
		
		//事件聚焦
		//this.G.letter.default_eventFocus();
		if(fn!=null && typeof str != 'object'){
			fn(str,uid);
		};
	},
	
	setClassName :function(o,c){
		
		if(typeof o === 'object'){
			for(var i in c){
				o.className = c[i];
			}
		}
	},
	
	select_letters:function(){
		
		var _thi = this,ajax_date;
		if(elementClickEvent.gid('userShare_txt')!=null){
			
			var elemshare = this.elemshares = elementClickEvent.gid('userShare_txt');
			var node_list = this.node_list = elemshare.parentNode; //li
			if(node_list.getElementsByTagName('div')[0]){
				
				this.C = ajax_date = node_list.getElementsByTagName('div')[0];
				
			}
			
			node_list.style.cssText = 'position:relative;z-index:10;width:360px;';
			//node_list.appendChild(div);
			
			//输入查询用户
			elemshare['onkeydown'&&'onkeyup'] = function(){
				
				var thsVal = this.value.replace(/^\s+/,'').replace(/\s+/g,'');	
				
					if(thsVal.length !=0){
						_thi.setAjax(thsVal);
					}
			}
			
			
			document.onclick = function(event){
	
				if(_thi.getTag(event).nodeName !="INPUT" && _thi.getTag(event).nodeName !="P"){
					ajax_date.className = 'ajax_date hide';
					//document.onclick = null;//销毁事件
				}
				
			}
			
		}
	},
	
	setAjax:function(val){
		
		
		var XHR,docm = document,elementsArr =[],_ths=this;
		var url = G_BASE_URL + '/search/ajax/search/type-user__q-'+encodeURIComponent(val)+'__limit-10';
		this.C.className='ajax_date';
		 
		try{
			_ths.C.innerHTML='<img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...';
			
			XHR = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
			XHR.open("post",url,true);
			XHR.onreadystatechange = function(){
			
				if( XHR.readyState == 4 && XHR.status == 200 ){
				
					var XML = new Function('return '+XHR.responseText)();
					
					if(XML!=null && XML!=''){
						for(var i =-1,len =XML.length; ++i<len;){
							
							var elment,el = XML[i];
								elment = '<p id="'+el.uid+'" rel="'+el.name+'" onclick="elementClickEvent.letter.elem_add(event);">'+el.name+'</p>'
								elementsArr.push(elment);
								
						}
						
						_ths.C.innerHTML = elementsArr.join('');
					}else{
						
						_ths.C.innerHTML ='<p>sorry！没有查询到你要的用户.</p>';
					}
				}
			};
			XHR.send(null);
			
		}catch(e){
			 
			alert(e)
		}
	},
	
	elem_add : function(event){
		
		if(this.getTag(event).nodeName ==='P'){
		
			
			var rel = this.getTag(event).getAttribute('rel');
			var s = document.createElement('a');
			this.elemshares.className = 'txt_input hide';
			
				s.className = 'user';
				s.setAttribute('onclick','elementClickEvent.letter.removeObj(this,event);');
				s.setAttribute('rel',rel);
				s.title ='点击修改';
				s.href='javascript:;';
				s.innerHTML = rel+'<em rel='+rel+'>修改</em>';
				this.elemshares.value = rel;
			
			this.node_list.appendChild(s);
			this.C.className = 'ajax_date hide';
		}
	},
	
	removeObj:function(x,event){

		
		if(this.getTag(event).nodeName === 'A' || this.getTag(event).nodeName === 'EM'){
			
			var val = this.getTag(event).getAttribute('rel');
			
			this.elemshares.className = 'txt_input';//text框
			this.elemshares.value = val;
			this.elemshares.setAttribute("value",val);
			if(this.getTag(event).nodeName === 'EM'){
				
				this.node_list.removeChild(this.getTag(event).parentNode);//A
			}else{
				this.node_list.removeChild(this.getTag(event));//A
			}
			this.elemshares.select();
		}
		
	},
	
	moudle_box:function(str){
		
		//验证码
		var autoCode = '<div class="default_replenish"><input name="seccode_verify" type="text" class="default_autoCode">&nbsp;&nbsp;<span class="default_aotoNum"><img id="captcha" onclick="this.src = \'' + G_BASE_URL + '/account/captcha/rnd-\'+Math.random();" title="点击换一张" src="' + G_BASE_URL + '/account/captcha/"></span></div>';
		
		var _v2 = this ,moudle_staticHTML = '<div class="default_error hide" id="tip_quick_publish_message"></div><div class="default_addQuestion">'+
								'<form action="' + G_BASE_URL + '/publish/ajax/publish_question/" method="post" id="quick_publish" onsubmit="return false">';
								
								if (typeof(G_POST_HASH) != 'undefined')
								{
									moudle_staticHTML += '<input type="hidden" name="post_hash" value="' + G_POST_HASH + '" />';
								}
								//添加内容输入框
								moudle_staticHTML += '<div class="default_replenish default_quesions"><input type="text" name="question_content" id="question_start" class="default_Question_txt" value="请输入您要发起的问题..." onfocus="if(this.value==\'请输入您要发起的问题...\'){this.value=\'\';};this.style.color=\'#333\';" onblur="if(this.value==\'\'){this.value=\'请输入您要发起的问题...\';};this.style.color=\'#999\';" style="color:#999;"/><div class="question_ajax hide" id="question_ajax"><p class="question_ask"><a href="javascript:;" class="qes_x" title="点击关闭">不是<em>close</em></a>你想问的是不是下面这些问题？</p><div class="maxAtuo"></div></div></div>'+
		
								//问题补充
								'<div class="default_replenish"><p class="defa_qsadd" onclick="elementClickEvent.letter.default_AddQs(event);">问题补充<span class="defa_s">可选</span></p><div class="default_txtDiv hide"><textarea id="default_Question_textarea" class="default_Question_textarea" name="question_detail"></textarea></div></div>'+
								
								//选择分类
								'<input type="hidden" name="category_id" value="0" id="category_id" /><div class="default_replenish"><p id="defa_qsadd" class="defa_qsadd" onclick="elementClickEvent.letter.EveDefaultHide(event,'+str+');"><span class="defa_aor">箭头</span><span id="add_class_txt">选择分类</span></p><ul class="default_class_list hide"><li><img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...</li></ul></div>'+
								
								//添加话题
								//'<div class="default_replenish add_topic_v1"><div class="add_topic_class hide" id="add_topic_class"></div><input type="text" name="" id="default_addTopic" class="default_addTopic" style="border:0 none;" value="添加话题"/></div><div style="position:relative;"><div class="default_ajax_deta hide" id="default_ajax_deta"></div><div id="tips" class="tips_tak hide"></div></div>'+
								//验证码
								(G_QUICK_PUBLISH_HUMAN_VALID==1 ? autoCode :'')+
								
								//取消
								'<div class="default_replenish default_exit"><p class="f_default_exit"><a href="javascript:;" class="exit" onclick="hidePupBox(\'w_tagPupD\',\'w_mask\');" title="取消添加">取消</a>&nbsp;&nbsp;<a href="javascript:;" class="default_blue_but" onclick="event_onsubmit(\'#question_start\'); return false;" title="点击确定发起该问题 »">确定</a></p><!--<input type="checkbox" id="default_toPic_txt"/><label for="default_toPic_txt"> 匿名添加话题 </label>--><a href="#" onclick="$(\'form#quick_publish\').attr(\'action\', G_BASE_URL + \'/publish/\'); document.getElementById(\'quick_publish\').submit(); return false;" style="color:#666;">高级模式</a></div>'
								'</div>' + 
								
								'</form>'; 
								
		var moudle_title = '<a title="点击关闭对话框 " class="close_ti" onclick="hidePupBox(\'w_tagPupD\',\'w_mask\');" href="javascript:;"><em>close</em></a>';
		
		return{
			
			moudle_show_addDOM:function(fn){
				
				var x = new DialogBox_show('500',moudle_staticHTML,moudle_title+'发起','',function(){
					
					var w_tagPupD = _v2.G.gid('w_tagPupD');
						w_tagPupD.style.marginTop = '-130px';
						w_tagPupD.style.position = 'absolute';
						
						if(fn!=null){
							var s = setTimeout(function(){
								fn(_v2);
								clearTimeout(s);
							},100);
						}
				});
				
			},
			
			//问ta
			questionfor_user:function(str,uid){
			
				var obj_id = _v2.G.gid('w_tagPupD');	
					obj_id.style.position = 'fixed';
					obj_id.getElementsByTagName('h3')[0].innerHTML = moudle_title+'向&nbsp; '+str+' &nbsp;发问';
					
				var input = document.createElement('input');
					input.type ='hidden';
					input.name ='ask_user_id';
					input.value = uid;
					document.getElementById('quick_publish').appendChild(input);
			},
			
			//搜索发起问题
			
			start_question:function(str){
				var question_start = _v2.G.gid('question_start');
					question_start.value = str;
					question_start.setAttribute('value',str);
					_v2.G.gid('default_search').className = 'default_search hide';
					
			}
		}
		
		
	},
	
	question_start: function(_v2){
		//var url = G_BASE_URL+'/search/ajax/search/type-question&q='+val+'__limit-10';
		var query_obj = elementClickEvent;
		var question_start_id = query_obj.gid('question_start');
		var question_ajax_id = query_obj.gid('question_ajax');
			//
			question_start_id['onkeydown'&&'onkeyup'] = function(){
				
			var _v2_Value = this.value.replace(/^\s+/,'').replace(/\s+/g,'');	
				if(_v2_Value.length !=0){
					
					query_obj.letter.question_querySelect(_v2_Value,question_ajax_id);
					var s = document.onclick = function(event){
						
						if(_v2.getTag(event).className == 'b' || 
						   _v2.getTag(event).className == 'w_Contxt' ||
						   _v2.getTag(event).className == 'qes_x' ||
						   _v2.getTag(event).className == 'e' ||
						   _v2.getTag(event).className == 'default_replenish default_exit' ||
						   _v2.getTag(event).className == 'w_mask'||
						   _v2.getTag(event).id == 'default_Question_textarea'
						  ){
							question_ajax_id.className = 'question_ajax hide';
							s = null;//销毁事件
						}
						
					}
				}else if(_v2_Value.length <=0){
					question_ajax_id.className = 'question_ajax hide';
				}
				
			}
			
			
		
	},
	
	//话题首页头像编辑按钮显隐
	default_Evs :function(e){
		
		var default_id = this.G.gid('default_upLoad');
		
		if(this.getTag(e).nodeName.toLowerCase() ==='img' || this.getTag(e).nodeName.toLowerCase() ==='li'){
		
			
			var imgs = this.getTag(e);
			var imgs_li = imgs.parentNode;
			var elments = imgs_li.getElementsByTagName("a")[0];
			
				elments.className = 'editor_htFace';
				//default_id.style.top = pseInt(default_id.style.top) + 60 +'px';
			
			var Ev_defaultEvents = function(){
					
				elments.className = 'editor_htFace hide';
						
			}
			
			default_id['onmouseout'] = Ev_defaultEvents;
			
		}
		
	},
	
	//匿名身份操作
	
	default_anonymity : function(e){
		
		var _ths = this;
		if(this.getTag(e).nodeName.toLowerCase() ==='a'){
			
			var el = this.getTag(e).parentNode;
			var default_el = el.getElementsByTagName('p')[0];
			default_el.className = default_el.className == 'default_setPosition hide' ? 
			default_el.className = 'default_setPosition' : default_el.className = 'default_setPosition hide';
			
			var default_EvClick = document.onclick = function(e){
				
				if(_ths.getTag(e).nodeName.toLowerCase() !='a' && _ths.getTag(e).nodeName.toLowerCase() !='p'){
					
					default_el.className = 'default_setPosition hide';
					default_EvClick = null;//销毁事件
				}
			}
		}
		
	},
	
	question_querySelect:function(val,v2_id){
		
		var url = G_BASE_URL+'/search/ajax/search/type-question__q-'+encodeURIComponent(val);
		var XHR,elementsArr =[];
		var txt_v1 = '<p class="question_ask"><a title="点击关闭" class="qes_x" href="javascript:;">不是<em class="e">close</em></a>你想问的是不是下面这些问题？</p>';
		var txt_v2 ='<p class="question_ask"><a title="点击关闭" class="qes_x" href="javascript:;">关闭<em class="e">close</em></a>暂时未找到相关内容，你可以继续发起该问题，寻找最优解答。</p>';
		try{
				
			XHR = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
			XHR.open("post",url,true);
			XHR.onreadystatechange = function(){
			
				if( XHR.readyState == 4 && XHR.status == 200 ){
					
					var XML = new Function('return '+XHR.responseText)();
					if((XML && XML!=null) && XML!=''){
						for(var i =-1,len =XML.length; ++i<len;){
							
							var elment,el = XML[i];
								elment = '<p id="'+el.uid+'" title="'+el.name+'"><a href="'+el.url+'">'+(el.name.replace(new RegExp(val,"ig"),'<b>'+val+'</b>'))+'</a></p>'
								elementsArr.push(elment);
						}
						
						v2_id.innerHTML = txt_v1+'<div class="maxAtuo">'+elementsArr.join('')+'</div>';
					}else{
						
						v2_id.className ='question_ajax hide';
						v2_id.innerHTML='';
					}
				}else{
				
					v2_id.className = 'question_ajax';
					v2_id.innerHTML=txt_v1+'<div class="maxAtuo"><p><img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...</p></div>';
				}
			};
			XHR.send(null);
			
		}catch(e){
			 
			alert(e)
		}
	},
	
	//站内邀请
	default_invite : function( _v2x ){
		
		var default_id = this.G.gid('default_invite'),
			_ths = this,
			default_fun = this.default_seach;
			this.default_nums = _v2x.getElementsByTagName('span')[0];
			
			default_id.className = default_id.className == 'hide' ? 
								   (function(){
								   
										default_id.className = ''
										default_fun(_ths);
										
									})()
									 : default_id.className = 'hide';
		
			
	},
	
	//default_question
	default_question : function(obj,str,s){
		
		var el = obj.parentNode.parentNode;
		var a = el.getElementsByTagName('a');
		
		for(var i=-1,len=a.length;++i<len;){
			
			this.G.gid('layer_'+i).className = (i==str) ? s :s+' hide';
			a[i].className = (i==str) ? 'cur' :'';
		}
		
		
	},
	
	//公用显示更多操作
	default_more : function(e){
			
		var eventTag = this.getTag(e)	
		if(eventTag.nodeName.toLowerCase() === 'a' && eventTag.getAttribute('class') =='b'){
			
			eventTag.className = 'b cur';
		}else{
			
			eventTag.className = 'b';
		}
		
	},
	
	//站内用户搜索
	default_seach:function( obj ){

		if(obj.G.gid('default_seach_txt')!=null){
			
			var seach_input = obj.G.gid('default_seach_txt');
			var default_query = obj.G.gid('default_ajax_query');
			
				seach_input['onkeydown' &&'onkeyup'] = function(){
					
					var txtValue = seach_input.value.replace(/^\s+/,'').replace(/\s+/g,'');
					
					
					if(txtValue.length < 1){
						default_query.className = 'default_class_query hide';
					}else{
					
						var url = G_BASE_URL + '/search/ajax/search/type-user__q-' + encodeURIComponent(seach_input.value)+ '__limit-10';
						default_query.className = 'default_class_query';
						default_query.innerHTML='<p class="default_dateLister"><img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...</p>';
						obj.createXHR(url,default_query);
						
						//
						document.onclick = function(e){
							
							var event_tag = obj.getTag(e) , event_Case = event_tag.nodeName.toLowerCase();
							
							if(event_tag.getAttribute('id') !='default_ajax_query'&&
							   event_Case != 'p'    &&
							   event_Case != 'a'    &&
							   event_Case != 'span' &&
							   event_Case != 'img'
							){
								
								default_query.className = 'default_class_query hide';
							}
						}
						
					}
					
					
				}
		}
	},
	
	//邀请站内用户
	default_addUser:function(default_obj){
	
		var default_a = document.createElement('a'),_v2 = this;
		var obj_default = this.G.gid('default_inbites');
		var _v3num = _v2.default_nums.innerHTML.replace(/^\s+/,'').replace(/\s+/g,'');
		var _v3 = Number(_v3num);
		
		var ev_name = default_obj.getAttribute('Udate'),
			imgs_url = default_obj.getAttribute('url'),
			default_query = default_obj.parentNode;
			
			var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
				psotUrl = G_BASE_URL + '/question/ajax/add_invite/question_id-' + QUESTION_ID + '__uid-'+default_obj.getAttribute('uid');　
						　
				xmlHttp.open("post",psotUrl,true);　　　　
				xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");　　　　
				xmlHttp.onreadystatechange=function(){
							
					 if( xmlHttp.readyState == 4 && xmlHttp.status == 200 ){
								 
						var x = new Function('return'+xmlHttp.responseText)();
						if(x.errno == -1){
							var x_v2 = new DialogBox_show('200',x.err,'提示信息','确定');
							default_query.className ='hide';
							return false;
						}
						var imgs = '<img src="'+imgs_url+'" alt="'+ev_name+'" class="default_imgs" title="'+ev_name+'" />';
						var i_vorys = '<span class="default_select" title="取消邀请" onclick="elementClickEvent.letter.default_user(event,this);" uid="'+default_obj.getAttribute('uid')+'"></span><span  class="default_atten_nums">1</span>';
						default_a.className = 'default_user';
						default_a.innerHTML = imgs + i_vorys;
						obj_default.appendChild(default_a)
						default_query.className ='hide';	
						_v2.default_nums.innerHTML = _v2._v3_default_num = ++_v3;
						
					}
							
			};　
			　
			
			xmlHttp.send(null);
		
	},
	
	//站内邀请查询
	createXHR : function(url,x){

		var elementsArr =[],WIN_XHR = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
			WIN_XHR.open("post",url,true);
			WIN_XHR.onreadystatechange = function(){
				
				if( WIN_XHR.readyState == 4 && WIN_XHR.status == 200 ){
				
					var reps_Txt = new Function('return '+WIN_XHR.responseText)();
					
					if(reps_Txt!=null && reps_Txt){
						for(var i =-1,len =reps_Txt.length; ++i<len;){
							
							var elment,el = reps_Txt[i];
								elment = '<p class="default_dateLister" onclick="elementClickEvent.letter.default_addUser(this);" Udate="'+el.name+'" url="'+el.detail.avatar_file+'" uid="'+el.sno+'">'+
									     '<a href="javascript:;" class="default_userhead"><img src="'+el.detail.avatar_file+'" title="'+el.name+'" alt="'+el.name+'"/></a>'+el.name+
									     '<span class="default_span">'+el.detail.signature+'</span></p>'
								elementsArr.push(elment);
								
						}
						
						x.innerHTML = elementsArr.join('');
					}else{
						
						x.innerHTML ='<p class="default_dateLister">对不起！没有查询到你要的用户.</p>';
					}
				}
			}
			WIN_XHR.send(null);
	},
	
	//取消邀请
	default_user :function(e,default_obj){
		
		var _ths = this;
		var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
	　
		xmlHttp.open("post",G_BASE_URL + '/question/ajax/cancel_question_invite/question_id-' + QUESTION_ID+'__recipients_uid-'+default_obj.getAttribute('uid'),true);　　　　
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");　　　　
		xmlHttp.onreadystatechange=function(){
			
			 if( xmlHttp.readyState == 4 && xmlHttp.status == 200 ){
				 
				_ths.default_removeChild(e);
				_ths.default_nums.innerHTML = --_ths._v3_default_num;
			}
			
		};　
		　
		xmlHttp.send(null);
			
	},
	
	//发起问题选择分类
	
	EveDefaultHide:function(e,uid){
		
		
		var evels = this.getTag(e),txtDiv,_v2= this;
		var add_class_txt = this.G.gid('add_class_txt');
		
		if(evels.nodeName == 'P' || 
		   evels.nodeName == 'SPAN'){
			
			if( evels.nodeName == 'SPAN'){
				txtDiv = evels.parentNode.parentNode;
				evels = this.getTag(e).parentNode;
				
			}else if(evels.nodeName == 'P'){
				txtDiv = evels.parentNode;
			}
			var evSpan = evels.getElementsByTagName('span')[0];
			var eltags = txtDiv.getElementsByTagName('ul')[0];
				
				eltags.className = eltags.className == 'default_class_list hide' ? 'default_class_list' : 'default_class_list hide';
				evSpan.className = evSpan.className == 'defa_aor' ? 'defa_aor cur' : 'defa_aor';
					
				//缓存
				if(this.CacheClass.length <=0){
					var _xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
						_xhr.open("post", G_BASE_URL + '/publish/ajax/fetch_question_category/',true);
						_xhr.onreadystatechange = function(){
						
							if( _xhr.readyState == 4 && _xhr.status == 200 ){
								
								var ClassList_txt = new Function('return'+_xhr.responseText)();
									
									if(ClassList_txt!=null && ClassList_txt!=''){
										for(var i=-1,len = ClassList_txt.length;++i<len;){
											
											var _v1 = ClassList_txt[i];
											
											_v2.CacheClass.push('<li  class="'+(_v1.id == uid ? 'cur':'') +'" udate="'+_v1.title+'" uid="'+_v1.id+'"><a href="javascript:;">'+_v1.title+'</a></li>');
										
										}
										
										
									}else{
										
										eltags.innerHTML = '<p>暂无相关数据</p>';
									}
									
									eltags.innerHTML = _v2.CacheClass.join('');
									setValue_v3();
									
							}else{
							
								eltags.innerHTML = '<li><img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...</li>';
								
							}
						}
					_xhr.send(null);
					
					
					
				}else{
					
					eltags.innerHTML = _v2.CacheClass.join('');
					
				}
				
				//赋值
				function setValue_v3(){
					if(eltags.getElementsByTagName('li').length >=0){
						var element_li = eltags.getElementsByTagName('li');
						for(var i=-1,len=element_li.length;++i<len;){
											
							(function(i){
								var _$ = element_li[i];
									_$['onclick'] = function(){
													
									var udate = _$.getAttribute('udate');
										add_class_txt.innerHTML = udate+'<input type="hidden" name="'+_$.getAttribute('uid')+'" value="'+udate+'" />';	
										eltags.className = 'default_class_list hide';
										evSpan.className = 'defa_aor';
										if(_v2.G.gid('category_id')!=null){
											
											_v2.G.gid('category_id').value = _$.getAttribute('uid');
											_v2.G.gid('category_id').setAttribute('value',_$.getAttribute('uid'));
										}
									}
							 })(i)
						}
					}
				}					
				setValue_v3();	
				
		}
		
	},
	
	//发起问题-问题补充
	default_AddQs:function(e){
		
		var evels = this.getTag(e),tags,_ths = this;
		var defaultMinHeight = 60
			defaultMaxHeight = 500;
			
		if(evels.nodeName == 'P' || 
		   evels.nodeName == 'SPAN'){
			
			var txtDiv = evels.parentNode;
			var eleTags = txtDiv.getElementsByTagName('div')[0];
			var textareaTags = eleTags.getElementsByTagName('textarea')[0];
				
				if(evels.nodeName == 'SPAN'){
					tags = evels.parentNode;
				}else if(evels.nodeName == 'P'){
					tags = evels;
				}
				
				//txt框延伸
				textareaTags['onkeydown' && 'onkeyup'] = function(){
					
					var default_height = textareaTags.scrollHeight;
					textareaTags.style.height = '0px';
					textareaTags.style.overflowY = 'hidden';
					
					if(textareaTags.scrollHeight >= defaultMaxHeight ){
						
						textareaTags.style.height = defaultMaxHeight+'px';
						textareaTags.style.overflowY = 'auto';
						return false;
					}
					if(default_height > defaultMinHeight){
						textareaTags.style.height = '0px';
						textareaTags.style.height = textareaTags.scrollHeight+30+'px';
						
					}else{

						textareaTags.style.height = defaultMinHeight+'px';
					}
					
				} //end events;
				
				eleTags.className = 'default_txtDiv';
				tags.className = 'defa_qsadd hide';
				textareaTags['onblur'] = function(){
					
					if(textareaTags.value=='' ||
					   textareaTags.value==null){
							
						eleTags.className = 'default_txtDiv hide';
						tags.className = 'defa_qsadd';
					}
				}
				
				document.onclick = function(e){
					
					var _ = _ths.getTag(e);
					var _tag = _.nodeName.toLowerCase();
					
					if(_.getAttribute('id') !=null &&
  					   _.getAttribute('id')=='defa_qsadd'){
						
						if(textareaTags.value=='' ||
						   textareaTags.value==null){
							
							eleTags.className = 'default_txtDiv hide';
							tags.className = 'defa_qsadd';
							document.onclick = null;
						}
					}else if(_tag != 'p'  && 
					         _ != textareaTags && 
					         _ !=eleTags ){
						
						if(textareaTags.value=='' ||
						   textareaTags.value==null){
							
							eleTags.className = 'default_txtDiv hide';
							tags.className = 'defa_qsadd';
							document.onclick = null;
						}
						
					}
				}

		}
	},
	
	//发起问题-添加话题-查询
	default_Addtopic : function(){
		
		var _ths = this,p_v1='',p_v2=[];
		if(this.G.gid('default_addTopic')!=null && 
		   this.G.gid('default_ajax_deta')!=null
		  ){
			
			var element_topic = this.element_topic = this.G.gid('default_addTopic');
			var element_ajaxID = this.element_ajaxID = this.G.gid('default_ajax_deta');
				
				element_topic.onfocus = function(){
					if(element_topic.value == '添加话题'){
						element_topic.value ='';
					}
				}
				
				element_topic.onblur = function(){
					
					var _v3 = _ths.G.gid('add_topic_class');
					var _v2 = _v3.getElementsByTagName('span');
					if(_v2.length <=0){
					
						if(element_topic.value == ''){
							element_topic.value ='添加话题';
						}
					}
					
				}
				
				element_topic['onkeydown' && 'onkeyup']= function(){
					
					var txtValues = element_topic.value.replace(/^\s+/,'').replace(/\s+/g,'');
					
					    if(txtValues!=null && txtValues!=''){
						
						
						var _xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
							_xhr.open("post",G_BASE_URL+'/search/ajax/search/type-topic_add__q-'+txtValues+'__limit-100',true);
							_xhr.onreadystatechange = function(){
						
								if( _xhr.readyState == 4 && _xhr.status == 200 ){
								
									var x = new Function('return'+_xhr.responseText)();
									if(x!=null && x!=''){

										for(var i=-1,len= x.length; ++i<len;){
										  
										 
											if(i!=0){
												p_v2.push('<p class="ajax_lsit" onclick="elementClickEvent.letter.default_setAjax(this);" rel="'+x[i].name+'" uid="'+x[i].sno+'"><img src="'+x[i].detail.topic_pic+'" rel="'+x[i].name+'"/>'+x[i].name+'<span rel="'+x[i].name+'">'+x[i].detail.focus_count+'人关注</span></p>');
											}else if(i==0){
												if(x[i].exist == 1){
													p_v1 = '';
													
												}else if(x[i].exist == 0){
													p_v1 = '<p class="add_Topic" onclick="elementClickEvent.letter.default_setAjax(this);" id="add_Topic" uid="'+parseInt(Math.random()*1000)+'" rel="'+txtValues+'">添加<span>'+txtValues+'</span>话题</p>';
													
												}
											}
											
										}
										element_ajaxID.className = 'default_ajax_deta';
										element_ajaxID.innerHTML = p_v1 + p_v2.join('');
										p_v2=[];
									}else{
										
										element_ajaxID.className = 'default_ajax_deta';
										element_ajaxID.innerHTML = '<p class="add_Topic">对不起！没有查询到你要的数据。</p>';
									}
									
								}else{
									
									element_ajaxID.className = 'default_ajax_deta';
									element_ajaxID.innerHTML = '<p class="add_Topic"><img src="' + G_STATIC_URL + '/common/load.gif"> 正在加载，请稍后...</p>';
								}
							}
							_xhr.send(null);
							
						}else{
							element_ajaxID.className = 'default_ajax_deta hide';
							//element_ajaxID.innerHTML = '<p class="add_Topic">对不起！没有查询到你要的数据。</p>';
						}
				

					//
					document.onclick = function(e){
						
						if(_ths.getTag(e) != element_ajaxID){
							
							element_ajaxID.className = 'default_ajax_deta hide';
							element_topic.value = '';
							element_topic.setAttribute('value','');
							document.onclick = null;
						}
						
					}
				}
		}
		
	},
	
	//添加话题
	default_setAjax : function(e){
		
		
		var add_topic_class = this.add_topic_class = this.G.gid('add_topic_class');
		var top_v2 = this.G.gid('tips');
		var element_UID = e.getAttribute('uid');
		var _v0 = '<input type="hidden" name="topics[]" value="'+e.getAttribute('rel')+'"/>';
		var span = document.createElement('span');
			span.className ='s';
			span.setAttribute('uid',element_UID);
			span.innerHTML = e.getAttribute('rel')+'<em title="删除话题" onclick="elementClickEvent.letter.default_topChild(event);"></em>'+_v0;
			
		if(e.getAttribute('id') == 'add_Topic'){
			
			add_topic_class.appendChild(span);
			add_topic_class.className = 'add_topic_class';
			this.element_ajaxID.className = 'default_ajax_deta hide';
			this.element_topic.value = '';
			this.element_topic.setAttribute('value','');
			return false;
			
		}else{
		
			if(add_topic_class.getElementsByTagName('span').length <= 0){
				add_topic_class.appendChild(span);
				add_topic_class.className ='add_topic_class';
				return;
			}else{
				
				var element_top_span =  add_topic_class.getElementsByTagName('span');
				for(var i=-1,len = element_top_span.length; ++i<len;){
					
					var element_ID = element_top_span[i].getAttribute('uid');
					if(element_ID == element_UID){
						
						var top_v3 = '<p>请勿重复添加，谢谢！</p><a href="javascript:;" class="a" onclick="javascript:this.parentNode.className=\'tips_tak hide\';">确定</a>';
						top_v2.innerHTML = top_v3;
						top_v2.className = 'tips_tak';
						return false;
					}
					
 				}
				
				add_topic_class.appendChild(span);
				add_topic_class.className ='add_topic_class';
			}
			
			this.element_ajaxID.className = 'default_ajax_deta hide';
			this.element_topic.value = '';
			this.element_topic.setAttribute('value','');
		}
		
	},
	
	//话题input聚焦事件
	default_eventFocus : function(){
		
		var element_Div = this.element_topic.parentNode,e = this;
			
			element_Div['onclick' || 'onmousedown' || 'onmouseover'] = function(){
				
				e.element_topic.focus();
			}
	},
	
	default_removeChild : function(e){
		typeof e === 'object' ? 
		e.parentNode.parentNode.removeChild(e.parentNode) : 
		this.getTag(e).parentNode.parentNode.removeChild(this.getTag(e).parentNode);
		
	},
	
	default_topChild: function(e){
		
		//删除节点
		this.default_removeChild(e);
		
		var element_span = this.add_topic_class.getElementsByTagName('span');
		if(element_span.length <=0){
			this.add_topic_class.className ='add_topic_class hide';
		}
		
	},
	
	
	reply_User: function(e,id,user){
		
		var uservalue = '@'+user;
		
		if(this.getTag(e).nodeName === 'A'){
			
			var input_id = this.G.gid(id);
			var defaultObjValue = input_id.value;
			
			if (defaultObjValue.indexOf(uservalue) == 0)
			{
				return false;
			}
			
			if(defaultObjValue == '' && defaultObjValue.length <= 0){
				
				//default_arr = [];
				input_id.value = uservalue + ' ';
				input_id.setAttribute('value', uservalue + ' ');
			
			}else if(defaultObjValue.length > 0){
					
				input_id.value = defaultObjValue+uservalue+' ';
				input_id.setAttribute('value',defaultObjValue+uservalue+' ');
					
			}
			
			input_id.focus();
			
		}
		
	}
	
	
}

//none_bd cur 

strClick_show.prototype.clickSort= function(e){
	
	try{var default_id = this.gid('default_liste_module');}catch(w){}
	
	if(default_id!=null){
		
		var span = this.letter.getTag(e).getElementsByTagName('span')[0];
		var node_bd = this.letter.getTag(e);
		if(this.letter.getTag(e).nodeName.toLowerCase()=='span'){
			var s = this.letter.getTag(e);
			
			node_bd = s.parentNode;
			span = s;
			
		}
		
		if(span.className!='default_arr'){
			
			node_bd.title='展开 »';
			span.className = 'default_arr';
			node_bd.className='default_tal default_class';
			default_id.className='default_liste_module hide';
		}else{
			node_bd.title='收起 »';
			span.className = 'default_arr cur';
			node_bd.className='default_tal default_class none_bd';
			default_id.className='default_liste_module';
		}
	}
}


function default_hide(){
	
	try{
		
		if(document.getElementById('default_edite')!=null){
			
			document.getElementById('default_edite').style.display='';
		}
		
	}catch(e){}
}





//小卡片，私信，话题

var d=document,
	usersinfo,              //用户、话题
	josnDate=[],            //缓存数据
	Quick_Tips;           //私信
	

window.onload = function(){

loadAddElements();

function default_anwsion(){
	
	this.d = document;
	this._$fb = function(o){return 'string' == typeof o ? this.d.getElementById(o) : o ;};                //获取ID
	this.seif ='';
	
	this.options = {
	
				users: this._$fb('user-opacity-tips'),                                                    //名片ID
			   ukMask: this._$fb('uk-mask'),                                                              //遮罩
			    fbPgk: this._$fb('fb-pgk'),
	  _$showClassName: 'user-opacity-tips ',                                                               //
_$showClassName_topic: 'user-opacity-tips default_topic_opacity', 
	  _$hideClassName: 'user-opacity-tips hide',
				  pos: 'static',
				   px: 'px',
				   _x: '',                                                                                 //获取元素左边距
				   _y: '',                                                                                 //上边距
			_soffsetX: '',
			_soffsetY: '',
				elObj: '',
			 userOffs: '',
					x: '',
					y: '',
				  E_C: 0 ,
		    Obj_width: 330,
		  topic_width: 268
		
	}
}

//鼠标经过
default_anwsion.prototype._s = function(s,url,bl,fn){

	var _this = this,obj_w;
	var R = document.documentElement.scrollWidth || document.body.scrollWidth ;// safari firefox IE
	if(bl){
		obj_w = this.options.Obj_width;//个人
		
	}else{
		obj_w = this.options.topic_width;//话题
		
	};
	
	//
	if(R-(s.getBoundingClientRect().left+obj_w) < 100 ){
	
		//this.options.E_C = 230;
		 
		bl ? this.options.E_C = 230 : this.options.E_C = 163;
		this.setCss(this._$fb('fb-span').style,{left:'auto',right:'50px'});
	}else{
		this.options.E_C = 0;
		this.setCss(this._$fb('fb-span').style,{left:'40px',right:'auto'});
	}
	this.options._x = s.getBoundingClientRect().left+(this.d.documentElement.scrollLeft+this.d.body.scrollLeft);
	this.options._y = s.getBoundingClientRect().top+(this.d.documentElement.scrollTop+this.d.body.scrollTop);
	
	if(s.offsetWidth <= 36 && s.offsetWidth > 30){
		this.options._soffsetX = s.offsetWidth;
	}else if(s.offsetWidth <= 30 && s.offsetWidth > 0){
		this.options._soffsetX = s.offsetWidth+(s.offsetWidth/2);
	}else{
		this.options._soffsetX = s.offsetWidth/2;
	}
	
	this.options._soffsetY = s.offsetHeight+10;
	this.options.elObj = s.getAttribute("rel");
	
	this.options.x = this.options._x - (this.options._soffsetX+this.options.E_C)+this.options.px;
	this.options.y = this.options._y + this.options._soffsetY +this.options.px;
	this.seif = s;
	
	this.setCss( this.options.users.style,{top:this.options.y,left:this.options.x} ); 
	
	if(this.options.fbPgk.className.replace(/\s/g,'') == 'fb-pgk'){
		
		this.xhrAjax(s,url,bl);
	}
	
	this.setCss( this.options.users,{className:this.options._$showClassName} );	
	this.setCss( this.options.ukMask.style,{height:'47px'});
	this.$docHide(bl);
	
	s.onmouseout = function(){_this.$uHide()};
	
	if(fn!=null){
		fn();
	};
}


default_anwsion.prototype.EleAjaxHTML = function(elements){
	
		var ELAJAX_html='',AreaJobs='',Attentions,_this= this;
		//用户姓名
		ELAJAX_html = '<div style="min-height:53px;"><h3 id="uk-user-name"><a href="' + G_BASE_URL + '/people/'+ elements.user_name +'" title="点击进入'+elements.user_name+'的个人主页">'+ elements.user_name +'</a></h3>';
		
		//用户区域、职业
		/*if(elements.area != null && elements.job != null){
				if(elements.area){
					AreaJobs = '<p><span id="uk-user-address">'+ elements.area +'</span> <span id="uk-user-job">'+ elements.job +'</span></p>'; 
				}else{
					AreaJobs = '<p><span id="uk-user-job">'+ elements.job +'</span></p>'; 
				}
		}else{
		
			if(elements.area == null && elements.job != null){

				AreaJobs = '<p><span id="uk-user-job">'+ elements.job +'</span></p>';
				
			}else if(elements.area != null && elements.job == null){
					if(elements.area){
						AreaJobs = '<p><span id="uk-user-address" >'+ elements.area +'</span></p>';	
					}
			}else{
				
				AreaJobs = '<p>这家伙很懒，什么也没留下。</p>';
			}
		}
		
		ELAJAX_html += AreaJobs;*/
		ELAJAX_html += '<div class="default_taginfo">';
		if(elements.reputation >=0 && elements.thanks_count >=0 && elements.agree_count >=0){
			ELAJAX_html +='<span title="威望 '+elements.reputation+'">威望<em class="e">'+elements.reputation+'</em></span>|<span title="赞同 '+elements.agree_count+'">赞同<em>'+elements.agree_count+'</em></span>|<span title="感谢 '+elements.thanks_count+'">感谢<em>'+elements.thanks_count+'</em></span>';
		}
		ELAJAX_html += '</div>';
		//用户头像
		ELAJAX_html += '<span  class="uk-img" id="uk-user-img" ><a href="' + G_BASE_URL + '/people/'+ elements.user_name +'"><img src="'+ elements.avatar_file +'" alt="'+ elements.user_name +'" title="'+ elements.user_name +'"/></a></span>';
		
						
		//用户签名
		if(elements.signature == null || elements.signature==''){
			ELAJAX_html += '</div><div class="default_user_autograph"><p class="fnCor" id="uk-user-txt" title="暂无签名">暂无签名</p></div>' ;
		}else{
			ELAJAX_html += '</div><div class="default_user_autograph"><p class="fnCor" id="uk-user-txt" title="'+elements.signature+'">'+ elements.signature +'</p></div>' ;
		}
		
		if (G_USER_ID > 0) {
		
			//用户积分
			ELAJAX_html+='<div class="fk-uR">';
			//ELAJAX_html += '<div class="fk-uR"><span class="c0_1">积分：<em id="uk-user-integral">'+ elements.integral+'</em></span>';	
			//用户关注
			if(!elements.is_me){
				
				if(elements.focus){
			
					Attentions =  '<span class="c0_3 cur" id="fb_Attention" uid="'+_this.options.elObj+'" onclick="Attention(this,true);" title="取消关注">取消关注</span>';
				}else{
					
					Attentions =  '<span class="c0_3" id="fb_Attention" uid="'+_this.options.elObj+'" onclick="Attention(this,true);" title="关注">关注</span>';
				}
				
				ELAJAX_html += Attentions;
				
				ELAJAX_html += '<span class="default_USER_info"  onclick="usersinfo.Callback();Quick_Tips.info(this,\''+elements.user_name+'\');" ><a href="javascript:;" title="发送私信">私信</a></span><span class="default_USER_info default_forQs" onclick="usersinfo.Callback();elementClickEvent.letter.moudleTips_start(\''+elements.user_name+'\',elementClickEvent.letter.moudle_box().questionfor_user,\''+_this.options.elObj+'\');"><a href="javascript:;" title="点击向Ta发起问题">问Ta</a></span></div>';
				
			}else{
				ELAJAX_html +='<span style="margin-right:20px;">我自己</span></div>';
			}
			
			
		}
	
		
	var setTime = setTimeout(function(){
		
		_this.options.fbPgk.innerHTML = ELAJAX_html;
		_this.options.userOffs = _this.options.users.offsetHeight;
		_this.setCss( _this.options.ukMask.style,{height:_this.options.userOffs+_this.options.px});
		
		clearTimeout(setTime);
		
		
	},10);
}


default_anwsion.prototype.EleAjaxHTML_HT = function(elements){
	
	var x = this.options._x +this.seif.offsetWidth -((this.seif.offsetWidth/2)+this.options.E_C)-50;
	
	this.setCss( this.options.users.style,{top:this.options.y,left:x+'px'}); 
	var ELAJAX_html='',AreaJobs='',Attentions,_this= this;
	
		//话题标题
		ELAJAX_html = '<div style="min-height:60px;"><h3 id="uk-user-name"><a href="'+G_BASE_URL+'/topic/'+ elements.topic_title +'" title="点击进入'+elements.topic_title+'话题主页">'+ elements.topic_title +'</a></h3>';
		
		//话题描述
		if(elements.topic_description !=''){
		
			AreaJobs = '<p class="fnCor" id="uk-user-txt" title="'+elements.topic_description+'">'+elements.topic_description.substring(0,28) +'...</p></div>' ;
		}else{
			
			AreaJobs = '<p class="fnCor">没有任何关于此话题的相关描述</p></div>' ;
		}
		
		ELAJAX_html += AreaJobs;
		
		//话题logo
		ELAJAX_html += '<span  class="uk-img" id="uk-user-img" ><a href="'+G_BASE_URL+'/topic/'+ elements.topic_title +'" title="点击进入'+elements.topic_title+'话题主页"><img src="'+ elements.topic_pic +'" alt="'+ elements.topic_title +'" title="'+ elements.topic_title +'"/></a></span>';
		
		//话题关注
		if (G_USER_ID > 0) {
			if(elements.focus){
			
				Attentions = '<div class="fk-uR"><span class="c0_3 cur" id="fb_Attention" uid="'+_this.options.elObj+'" onclick="Attention(this,false);" title="取消关注">取消关注</span>';
			}else{
					
				Attentions =  '<div class="fk-uR"><span class="c0_3" id="fb_Attention" uid="'+_this.options.elObj+'" onclick="Attention(this,false);" title="关注">关注</span>';
			}
	
			ELAJAX_html += Attentions;
		}else{
			ELAJAX_html+='<div class="fk-uR">';
		}
		
		//问题数 关注数
		if(elements.focus_count && elements.topic_count){
			ELAJAX_html += '<span>问题数<em>'+elements.topic_count+'</em></span> | <span>关注者<em>'+elements.focus_count+'</em></span></div>';
		}else{
			ELAJAX_html += '<span>问题数<em>0</em></span> | <span>关注者<em>0</em></span></div>';
		}
		
	var setTime = setTimeout(function(){
		
		_this.options.fbPgk.innerHTML = ELAJAX_html;
		_this.options.userOffs = _this.options.users.offsetHeight;
		_this.setCss( _this.options.ukMask.style,{height:_this.options.userOffs+_this.options.px});
		
		clearTimeout(setTime);
		
		
	},10);
}
default_anwsion.prototype.xhrAjax = function(s,url,e){
					
	var _this= this;

	if(josnDate.length <=0){
		
		this.setAjax(url);
			
	}else{
		
		var rel= s.getAttribute("rel").replace(/\s/g,'');
		
		for(var i in josnDate){
			
			if(josnDate[i].uid == rel && e){
				
				_this.EleAjaxHTML(josnDate[i]);
				return false;
				
			}else if(josnDate[i].topic_id == rel && !e){

				_this.EleAjaxHTML_HT(josnDate[i]);
				return false;
			}
			
		}
    	this.setAjax(url);
	 	    
	}
	
	
}

default_anwsion.prototype.setAjax = function(url){
	
	var _this = this,xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
	
		xhr.open("post",url+this.options.elObj,true);
		xhr.onreadystatechange = function(){
						
			if( xhr.readyState == 4 && xhr.status == 200 ){
				
				var elements = new Function('return'+xhr.responseText)();
	
					
					
					if(elements.type == 'people'){
					
						_this.EleAjaxHTML(elements);	
						josnDate.push({
						
									"uid":elements.uid,                //用户ID           
							  "user_name":elements.user_name,          //用户名
							"avatar_file":elements.avatar_file,        //用户头像
								   "area":elements.area,               //用户地域
									"job":elements.job,                //用户职业
							  "signature":elements.signature,          //用户签名
							   "integral":elements.integral,           //用户积分
							"award_count":elements.award_count,        //获奖次数
							 "reputation":elements.reputation,         //威望
							"agree_count":elements.agree_count,        //赞同
						   "thanks_count":elements.thanks_count,       //感谢
								  "focus":elements.focus,              //关注
								  "is_me":elements.is_me,              //本人
								   "type":elements.type                //用户名片夹
						});
						
					}else if(elements.type =='topic'){
						
						_this.EleAjaxHTML_HT(elements);
						josnDate.push({
					
							 "topic_id":elements.topic_id,               //话题ID           
						  "topic_title":elements.topic_title,            //话题标题
					"topic_description":elements.topic_description,      //话题描述
							"topic_pic":elements.topic_pic,              //话题logo
					      "focus_count":elements.focus_count,            //关注人数
							    "focus":elements.focus,                  //关注
						  "topic_count":elements.topic_count,            //问题数
								 "type":elements.type                    //话题
						});
						
					}
				
			}else{
				
				_this.options.fbPgk.innerHTML = '请稍后，正在加载...';
				
			}
		};
		xhr.send(null);

}

default_anwsion.prototype.getEvent = function (event) {
        return event ? event : window.event;
    }
default_anwsion.prototype.getTarget = function (event) {
        return event.target || event.srcElement;
    }
default_anwsion.prototype.addHandler = function (element, type, handler) {
        if (element.addEventListener) {
            element.addEventListener(type, handler, false);
        } else if (element.attachEvent) {
            element.attachEvent("on" + type, handler);
        } else {
            element["on" + type] = handler;
        }
    }
default_anwsion.prototype.getRelatedTarget = function (event) {
        if (event.relatedTarget) {
            return event.relatedTarget;
        } else if (event.toElement) {
            return event.toElement;
        } else if (event.fromElement) {
            return event.fromElement;
        } else {
            return null;
        }
    }

default_anwsion.prototype.isMouseLeaveOrEnter = function( o,e){  //mouseout、mouseover兼容火狐的解决方案
 
    if (e.type != 'mouseout' && e.type != 'mouseover') return false;  
    var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;  
    while (reltg && reltg != o)  
        reltg = reltg.parentNode;  
    return (reltg != o);  
}  


default_anwsion.prototype.$docHide = function(fs){
	
	var x = this;
	
	
	x.addHandler(this.options.users,'mouseout',function(event){
		
		if(x.isMouseLeaveOrEnter( x.options.users,event )){
		
			x.options.users.className = x.options._$hideClassName;
			x.options.users.style.top='0px';
			x.options.users.style.left='0px';
		}
	})
	x.addHandler(this.options.users,'mouseover',function(event){
		
		if(x.isMouseLeaveOrEnter( x.options.users,event )){
			
			if(fs){
				x.options.users.className = x.options._$showClassName;
			}else{
				x.options.users.className = x.options._$showClassName_topic;
			}
		}
	})
}

default_anwsion.prototype.$uHide = function( s ){
	
	if(this.options.userOffs !=''){
		
		this.setCss( this.options.users,{className:this.options._$hideClassName} );
	}
} 

default_anwsion.prototype.setCss = function( o,Class ){

	for(var k in Class){
		
		o[k] = Class[k];
		
	}
}


default_anwsion.prototype.Callback = function(){
	this.options.users.className = this.options._$hideClassName;
}



var __quickPopUp = function(){
	
		var el = this;
		this.d = document;
		this.$ = function(str){return  'string' == typeof str ? el.d.getElementById(str) : str};
		this.bd = this.d.getElementsByTagName('body')[0];
		var _$= el.$ , wordsNumber = 500;
		
		this.element = '';
		this.tagDiv = _$('tagDiv');              //弹出层
		this.worDageTarea = _$('worDageTarea');  //文本输入框内容
		this.exit = _$('pm_popup_exit');		 //取消
		this.uName = _$('userName');             //私信用户名
		this.wordage = _$('wordage');            //字数
		this.submit = _$('submit');              //提交
		this.addUser = _$('addUser');
		this.mouseEvent = 'keyup';
		this.org = _$('org_alpha');
		this.offset = 'scrollHeight'||'offsetHeight';
		this.intxt = window.addEventListener ? 'textContent' : 'innerText';
		this.editor = d.createElement("span");
		this.As_close = _$('As_close');

		return {
			
				static : function( o,x,user ){
					
					var elementScrollheight;
							
								if(el.d.documentElement[el.offset] > el.d.body.scrollHeight){
									
									elementScrollheight = el.d.documentElement[el.offset];
								}else{
									
									elementScrollheight = el.d.body.scrollHeight;
								}
								
								el.org.style['height'] = elementScrollheight +'px';
								
								el.org.className = 'obg';
								
								el.tagDiv.className = 'tagDiv';
								var bsh = el.d.body.scrollHeight/2;
								var tsh = el.tagDiv[el.offset];
								
								x.setStyle(el.tagDiv,{'top':'15%'});
								
								x.mouseEve(x);
								
								if(user != null){
									
									var user_span = _$('addUser').getElementsByTagName('span');
									//防止多用户发送私信
									if(user_span!=null && user_span.length > 0){
										
										for(var i=-1,len = user_span.length;++i<len;){
											_$('addUser').removeChild(user_span[i]);
										}
										
									}
									x.extend(el.uName,{'className':'tx hide'});
									var a = '<a title="点击修改" href="javascript:void(0);">'+user+'<em>修改</em></a>';
									
										el.editor.className = 'user';
										x.extend(el.editor,{'className':'user','onclick':'deletes(this);','val':user});
										el.editor.innerHTML = a;
									_$('addUser').appendChild(el.editor);
									//_$('userName').setAttribute('value',user);
									_$('userName').value = user;
									
								}
						
						
				},
				
				createlements : function( element,x,obj ){
				
					var elements = el.d.createElement( element );
					
						x.extend(elements,obj);
					
						return elements;
						
				},
				
				addEvent : function(el,type,fn){
					
					if(window.addEventListener){
					
						el.addEventListener(type,fn,false);
						
					}else if(window.attachEvent){
					
						el.attachEvent('on'+type,fn);
						
					}else{
					
						el['on'+type] = fn;
					}
				
				},
				
				exit : function( x ){
				
					x.addEvent(el.exit,'click',function(){
						
						el.submit['disabled'] = 'disabled';
						el.org.className = 'obg hide';
						el.tagDiv.className = 'tagDiv hide';
						el.worDageTarea.value ='';
						el.uName.value ='';
						x.setStyle(el.worDageTarea,{'height':'80px'});
						el.wordage.innerHTML = '亲，你还可以输入<big class="big">500</big>个字噢。';
					});
					x.addEvent(el.As_close,'click',function(){
						
						el.submit['disabled'] = 'disabled';
						el.org.className = 'obg hide';
						el.tagDiv.className = 'tagDiv hide';
						el.worDageTarea.value ='';
						el.uName.value ='';
						x.setStyle(el.worDageTarea,{'height':'80px'});
						el.wordage.innerHTML = '亲，你还可以输入<big class="big">500</big>个字噢。';
					});
				},
				
				uerName : function( x ){

					var _el = el.uName,ajax = _$('ajaxDate');
						
					if(_el.value ==''){
								
						_el.value = '搜索用户';
					}
					
					x.addEvent(_el,'focus',function(){
						
						if(_el.value =='搜索用户'){
							
							_el.value ='';
							
						}
						_el.select();
					});
					
					x.addEvent(_el,'blur',function(){
													
						if(_el.value ==''){
							
							_el.value ='搜索用户';
						}else if(_el.value !='搜索用户'){
							
						}						
					});
					
					x.addEvent(_el,el.mouseEvent,function(){
						
						ajax.innerHTML ='';
						var ObjValue = _el.value.replace(/\s/g,'');
						
						if(ObjValue !='' && ObjValue.length >0){
						
							var url = G_BASE_URL+'/search/ajax/search/type-user__q-'+encodeURIComponent(ObjValue)+'__limit-10';
						
							x.XHRAjax(url,x,ajax); //ajax接口
							
							x.extend(ajax,{'className':'ajaxdate'});
						}else{
							x.extend(ajax,{'className':'ajaxdate hide'});
						}
						
						d['onclick'] = function(){  x.extend(ajax,{'className':'ajaxdate hide'}) };
						
					})
					
				},
				
				
				setStyle : function(el,obj){
				
					for(var k in obj){
					
						var tlp = obj[k];
						el.style[k] = tlp;
						
					}
					return el ;
				},
				
				mouseEve : function( o ){
					
					o.addEvent(el.worDageTarea,el.mouseEvent,function(){
						
						o.setStyle(el.worDageTarea,{'height':0+'px'});
						var twords = el.worDageTarea.value.length ;
						var len = wordsNumber - twords;
						var wsh = el.worDageTarea.scrollHeight;
						
						if (len < 0){
							
							el.submit['disabled'] = 'disabled';
							el.wordage.innerHTML = '<span style="color:red;">你输入的内容已超出<big class="big">'+(-len)+'</big>个字</span>';
							o.setStyle(el.worDageTarea,{'overflowY':'scroll','height':'320px'});
							return false;
							
							
						}else{

							el.wordage.innerHTML = '你还可以输入<big class="big">'+len+'</big>个字。';
							el.submit['disabled'] = false;
							o.setStyle(el.worDageTarea,{'height':wsh+65+'px','overflowY':'hidden'});
							
							if(wsh > 280){
								o.setStyle(el.worDageTarea,{'overflowY':'scroll','height':'320px'});
								return false;
							}
							
							if(el.worDageTarea.value ==''){el.submit['disabled'] = 'disabled';}
						}
						
						

					});
					
					o.addEvent(el.worDageTarea,'focus',function(){
					
						o.setStyle(el.worDageTarea,{'height':0+'px'});
						var wsh = el.worDageTarea.scrollHeight;
						o.setStyle(el.worDageTarea,{'height':wsh+63+'px','overflowY':'hidden'});
						if(el.worDageTarea.value ==''){el.submit['disabled'] = 'disabled';}
						
					});
					
					o.addEvent(el.worDageTarea,'blur',function(){
					
						if(el.worDageTarea.value ==''){
							o.setStyle(el.worDageTarea,{'height':'80px'});
							el.submit['disabled'] = 'disabled';
						}
					})
				},
				
				
				each : function(x,fn){
					
					for(var k=-1,len=x.length;++k<len;){
					
						fn.call(this,x[k],k);
					}
				},
				
				XHRAjax: function( url,x,ajax ){
					
					var xhr;
					try{
						
						xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");
						xhr.open("post",url,true);
						xhr.onreadystatechange = function(){
						
							if( xhr.readyState == 4 && xhr.status == 200 ){
						
								var xml = new Function('return'+xhr.responseText)();
								
								if(xml!=null && xml!=''){
									
									x.each(xml,function(date,objx){
								
									
									var elements = document.createElement("div");
										elements.className = 'rSri';
										elements.id = date.uid;
										elements.setAttribute("val",date.name);
										elements.onclick = function(){
											createElem(this);
										}
										//elements.setAttribute("onclick",'createElem(this);');
										elements.innerHTML = '<p class="usr">'+date.name+'</p>';
										ajax.appendChild(elements);
									
									})
								}else{
									
									ajax.innerHTML = '<p style="padding:8px;color:#666;">抱歉！没有查询到你找的用户。<p>'
								}
							}
						};
						xhr.send(null);
						
					}catch(e){
						
						alert(e)
					}
				},
				
				extend : function( destination, source ) {
				
					for (var property in source) {
					
						if(property == 'id'|| property == 'className'){
						
							destination[property] = source[property]

						}else{
							destination.setAttribute(property,source[property]);
						}
					}
					
					return destination;
				},
				
				info : function( o,user ){
					
					var exl = this ;
					this.static( o,exl,user ); //点击
					this.exit( exl );   //取消
					this.uerName( exl ); //搜索用户
				}
				
		};
};






function createElem(x){

	var userName = document.getElementById('userName');
	var ajaxdate = x.parentNode;
	var elementsSPAN = document.createElement("span");
	userName.value = x.getAttribute("val");
	//userName.setAttribute('value',x.getAttribute("val"));
	
	
	elementsSPAN.className = 'user';
	//elements.setAttribute('onclick','deletes(this)');
	elementsSPAN.setAttribute("val",x.getAttribute("val"));
	elementsSPAN.onclick = function(){deletes(this);}
	elementsSPAN['innerHTML'] = '<a href="javascript:void(0);" title="点击修改">'+x.getAttribute("val")+'<em>修改</em></a>';
	ajaxdate.parentNode.appendChild(elementsSPAN);
	userName.className = 'tx hide';
	ajaxdate.className = 'ajaxdate hide';
	
	//alert(document.getElementById('userName').value);
}


//私信对话

	var d = document;
	if(d.getElementById("inputTips")){
	
		var tips = d.getElementById("inputTips");
		var userAarea = d.getElementById("tUserInput");
		var USnum = 500,minHeight = 60;

		userAarea.style.height = userAarea.scrollHeight+ minHeight+'px';
		
		userAarea['onkeydown' && 'onkeyup'] = function(){
			
			if(this.value =='' || this.value.length == 0){
				d.getElementById('sendForm')['disabled'] = 'disabled';
			}else{
				d.getElementById('sendForm')['disabled'] = false;
			}
			
			var usLEN = userAarea.value.length;
			
			var fb_uN = USnum - usLEN;
			
			
			tips.className = 'sub';
			tips.innerHTML = '还可以输入<big class="big">'+fb_uN+'</big>个字';
			
			if(fb_uN < 0){
				
				d.getElementById('sendForm')['disabled'] = 'disabled';
				this.style.height = '300px';
				this.style.overflowY = 'auto';
				tips.className = 'sub crl';
				tips.innerHTML = '已超出<big class="big">'+ (-fb_uN) +'</big>个字';
				return false;
				
			}else{
				
				d.getElementById('sendForm')['disabled'] = false;
			}
			
			this.style.height = minHeight+'px';
			this.style.height = this.scrollHeight + minHeight +'px';

		}
	}


Quick_Tips = new __quickPopUp();//私信
usersinfo  = new default_anwsion();//用户、话题名片夹



} //end window onload   



function deletes(o){
	
	var userName = document.getElementById('userName');
	userName.value = o.getAttribute("val");
	userName.className ='tx';
	o.parentNode.removeChild(o);
}

//添加取消关注
function Attention(o,bl){

	var url='';
	
	if(bl){
		
		url = G_BASE_URL+'/follow/ajax/follow_people/uid-';//用户
	}else{
		
		url = G_BASE_URL+'/topic/ajax/focus_topic/topic_id-';//话题
	}
	
	 
	var uid = o.getAttribute("uid");
	
	var XHRhTTp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("microsoft.XMLHTTP");　
						　
	XHRhTTp.open("post",url+uid+'&rnd'+Math.random(),true);　　　　
	XHRhTTp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");　　　　
	XHRhTTp.onreadystatechange=function(){
		if( XHRhTTp.readyState == 4 && XHRhTTp.status == 200 ){
						
			var XHRREPOSETEXT = new Function('return'+XHRhTTp.responseText)();
			
				
				//更新关注缓存
				if(josnDate.length!=0){
					
					for(var i=0,len=josnDate.length;i<len;i++){
						
						if(bl){
							if(josnDate[i].uid ==uid && XHRREPOSETEXT.rsm.type =='remove'){
							
								josnDate[i].focus = false;
								o.innerHTML = '关注';
								o.setAttribute("title",'关注');
								o.className = 'c0_3';
								
							}else if(josnDate[i].uid ==uid && XHRREPOSETEXT.rsm.type =='add'){
							
								josnDate[i].focus = true;
								o.innerHTML = '取消关注';
								o.setAttribute("title",'取消关注');
								o.className = 'c0_3 cur';
							}
							
						}else{
						
							if(josnDate[i].topic_id ==uid && XHRREPOSETEXT.rsm.type =='remove'){
							
								josnDate[i].focus = false;
								o.innerHTML = '关注';
								o.setAttribute("title",'关注');
								o.className = 'c0_3';
								
							}else if(josnDate[i].topic_id ==uid && XHRREPOSETEXT.rsm.type =='add'){
							
								josnDate[i].focus = true;
								o.innerHTML = '取消关注';
								o.setAttribute("title",'取消关注');
								o.className = 'c0_3 cur';
							}
						}
						
					}
				}
		}
	}
				
	XHRhTTp.send();
}


//mouse event
//个人
function eventsMouseM(s){
	
	var url = G_BASE_URL+'/people/ajax/user_json/uid-';
	url == null? 
		(function(){
			return false;
		})() : 
		(function(){
			usersinfo._s(s,url,true);
		})();
}

//话题
function eventstalk(s){

	var url = G_BASE_URL+'/topic/ajax/topic_info/topic_id-';	
	url == null? 
		(function(){
			return false;
		})() : 
		(function(){
			usersinfo._s(s,url,false,function(){
				var userTips = $('#user-opacity-tips');
				$(userTips).addClass('default_topic_opacity');
			});
		})();
}



function loadAddElements(){

	var element = document,el = element.createElement("div"),PopHTML,//私信
		bd = element.getElementsByTagName('body')[0],
		
		elementsHTML = '<div class="user-opacity-tips hide" id="user-opacity-tips"><div class="m" id="uk-mask"></div>';
		elementsHTML+= '<div class="fb-pgk" id="fb-pgk">请稍后，正在加载...</div>';
		elementsHTML+= '<span id="fb-span"></span></div>';
		PopHTML ='<div class="tagDiv hide" id="tagDiv"><div class="tcon">';
		PopHTML +='<h3 id="drag"><a title="点击关闭对话框 " class="close_ti" id="As_close" href="javascript:;"><em>close</em></a>发私信</h3><div class="default_error hide" id="tip_pm_send"></div>';
		PopHTML +='<form id="pm_popup_form" action="'+G_BASE_URL+'/inbox/ajax/send/tips_id-share_send" method="post">';
		
		if (typeof(G_POST_HASH) != 'undefined')
		{
			PopHTML +='<input type="hidden" name="post_hash" value="' + G_POST_HASH + '" />';
		}
		
		PopHTML +='<ul class="u"><li id="addUser" class="addUser"><div id="ajaxDate" class="ajaxdate hide"></div><label>发给：</label><input class="tx" type="text" name="recipient" id="userName" value="" onkeydown="if (event.keyCode == 13) { return false; }" /></li>';
		PopHTML +='<li><label>内容：</label><textarea class="tarea" id="worDageTarea" name="message" maxlength="500"></textarea></li>';
		PopHTML +='<li class="subm"><a href="javascript:void(0);" class="sbumi" disabled="disabled" id="submit" onclick="$(\'#tip_pm_send\').hide(); ajax_post($(\'#pm_popup_form\'), _pm_form_processer); return false;"  title="提交">提交</a><a href="javascript:void(0);" class="exit" id="pm_popup_exit" title="取消">取消</a><span id="wordage">你还可以输入<big class="big">500</big>个字。</span></li>';
		PopHTML +='</ul></form>';
		PopHTML +='</div></div><div class="obg hide" id="org_alpha"></div>';
		
		el.innerHTML = elementsHTML + PopHTML;
		element.getElementsByTagName('body')[0].appendChild(el);
		
		
}

//发起问题判断
function event_onsubmit(id){
	$(id).focus(function(){
		if($('#tip_quick_publish_message').css('display') == 'block'){
			$('#tip_quick_publish_message').hide();
		};
	})
	
	var _v2_txtValue = $(id).val().replace(/^\s+/,'').replace(/\s+/g,'');

	if(_v2_txtValue.length <=0 || $(id).val() =='请输入您要发起的问题...'){
		$('#tip_quick_publish_message').show().html('请输入发起问题的相关内容');
		return false;
	}else if(_v2_txtValue.length >1 && _v2_txtValue.length <= 4){
		$('#tip_quick_publish_message').show().html('问题内容也太少了点吧！');
		return false;
	}else{
		$('#tip_quick_publish_message').hide(); 
		ajax_post($('form#quick_publish'), _tips_form_processer);
	}

}


//赞同人物更多

function agree_user_more(el)
{
	var new_ag_users = new Array();
	
	el.parent().find('[name=agee_people]').each(function (){
		var user = new Array();
		user[0] = $(this).attr('rel');
		user[1] = $(this).html();
		new_ag_users.push(user);
	});
	
	var count = 0;
	var new_aus_str = "";
	$(new_ag_users).each(function (i){
		new_aus_str += '<a href="' + G_BASE_URL + '/people/' + new_ag_users[i][1] + '" rel="' + new_ag_users[i][0] + '" onmouseover="eventsMouseM(this);" name="agee_people" class="a">' + new_ag_users[i][1] + '</a>';
		if(new_ag_users.length > ++count) new_aus_str += "、";
	});
	
	el.parent().html(new_aus_str);
}